﻿
Namespace PL.MESSDK
    Public Class ItemMaster_PL
        Inherits PLBase
        Implements IPLProcess

        Private _aQueryName As String

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
            _aQueryName = queryName
        End Sub
        Public Sub New()
            MyBase.New()
        End Sub

        Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function

        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()

            If IsDBNull(row("PrdID_FK")) Then
                row.SetColumnError("PrdID_FK", "Mandatory")
            End If
            If IsDBNull(row("SiteId_FK")) Then
                row.SetColumnError("SiteId_FK", "Mandatory")
            End If
            If IsDBNull(row("ByDefault")) Then
                row.SetColumnError("ByDefault", "Mandatory")
            End If
            If IsDBNull(row("Inactive")) Then
                row.SetColumnError("Inactive", "Mandatory")
            End If

            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub

        Public Function NewRecord(ByVal dataRow As DataRow) As Boolean Implements IPLProcess.NewRecord
            dataRow("ItemMasterID") = Guid.NewGuid
            dataRow("ByDefault") = False
            dataRow("Inactive") = False
            Return True
        End Function

        Public Function BatchRecords(ByVal dataRow() As DataRow) As Boolean Implements IPLProcess.BatchRecords
            Return True
        End Function

        Public Function CurrentRecord(ByVal dataRow As DataRow) As Boolean Implements IPLProcess.CurrentRecord
            Return True
        End Function

    End Class
End Namespace
